-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add bracket colors plugin #1221
base: master
Are you sure you want to change the base?
Conversation
Perhaps the description and/or commit message should mention #1148? |
d005a26
to
b75167c
Compare
I updated the commit message with a reference to that issue. Raindow brackets sounds cool, I wish I knew of that issue before starting this |
While "rainbow colours" sounds nice "Bracketcolors" is more descriptive, so a user looking for it is more likely to find it. |
Looks good! Thanks.
Full agree. I did a quick code review without having a deeper look at the logic. A few comments @asifamin13:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and could you please add your plugin to the list in the top README?
0ac738a
to
0850594
Compare
Thanks for the feedback!
|
@eht16 I incorporated your suggested changes. I'm still learning Github, I apologize if I'm not navigating this pull request correctly 😅 (at my work, I'm used to Gitlab) |
No worries, it's fine. |
bracketcolors/src/bracketcolors.cc
Outdated
static gchar char_at(ScintillaObject *sci, gint pos) | ||
/* | ||
|
||
----------------------------------------------------------------------------- */ | ||
{ | ||
return sci_get_char_at(sci, pos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: why the wrapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious: why the wrapper?
The documented return type of SCI_GETCHARAT
is int
, presumably for Unicode characters up to 32 bits in length. Squeezing that into an 8-bit(?) (g)char
needs an explicit cast.
The (implied) point that just using the returned (g)int
without a cast is worth considering. At the same time, the pos
argument might be safer as the (platform independent) Sci_Position
type. The API structures that can only index 32-bit positions are slated for eventual deprecation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documented return type of
SCI_GETCHARAT
isint
, presumably for Unicode characters up to 32 bits in length.
No, that's probably either because int
is "the" basic numerical type in C, or because of other historical reasons (and technically it is returned as a sptr_t
). In practice, the returned value comes from Document::ChatAt()
which returns a char
. So if if want to be picky, it's actually a char
stored into a sptr_t
.
Squeezing that into an 8-bit(?)
(g)char
needs an explicit cast.
Well, yes, but… actually no: this does not actually wrap SCI_GETCHARAT
, but Geany's own wrapper, sci_get_char_at()
which has the exact same signature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I was writing this, I was using the autoclose
plugin as a template which has this wrapper as well. I suspect the authors of autoclose
used the wrapper for convenience since it's used a lot, I don't really need it as bad to be honest.
c1f652e
to
1e9a8b0
Compare
? why removed |
To get your attention, it seems. |
Nah, it happens that people learning Git can stuff it up so bad its easier to start again, no problem. But unfortunately that disconnects the discussion. |
Instead of breaking the flow, just force-push your branch: |
Well, it usually is not easier, but people just don't know it 😅 |
Thats learning 😁 |
This is what I did, along with squashing several commits similar to this. I made the mistake of forgetting that I pressed the "sync with upstream" button (due to a warning I saw on the UI), and I ended up including (and taking ownership) of the upstream commits. Since the commits were all squashed together, I couldn't see a way to cleanly If any of yall can somehow reverse that mess, I owe you a beer. |
Here you go, that PR is restored and should match what you had in #1241, 🍻
1e9a8b0 was the commit this PR was at (as seen in the commits history before I force-pushed, and as you can see in the force-push notification above). The idea was to restore the branch to the state it had when this PR was closed so GitHub sees it as matching this PR, and accept re-opening this PR. If you didn't have that hash anymore, it means that Git's garbage collection got rid of it on your end (as it was an old commit not referenced by anything anymore); you could have gotten it back by fetching it from GitHub (as I did myself, |
e8a1d98
to
50ae403
Compare
@b4n you are a life saver, your next beer is on me 🍻 I didn't realize git had garbage collection, I'll be sure to This PR is back on track now 😄 |
48fdf9e
to
7bef4fd
Compare
Fixed a bug to address a case when nested brackets weren't getting their color updated when their parent gets updated |
Looks like a good improvement. In the future, though, I would concentrate on just getting a minimal working version merged, then touch it up later in small, traceable iterations. To paraphrase the famous saying of Valéry, a pull request is never finished; it's abandoned. |
Wise(ish) words, and its corollary, 'Every time a PR changes "somebody" has to re-check it and re-test it, and eventually "somebody" gets bored' :-) |
Understood. What it currently on this branch is the "minimal working version". There is one more feature I want to add (user defined colors via preferences menu/config file). I'm working on this now, hopefully to be finished this week. I'll keep that on a different commit
I'm fine being that "somebody" haha I've had fun writing this plugin. Do new plugin PRs getting pulled in on the next geany-plugins release? |
I added support for loading/saving settings via a |
I've been daily driving this plugin for several months now. I think it's stable enough to be merged. The latest CI build failure seems to be from misconfigured runners. |
The CI was awaiting a manual approval to run, approved, lets see. Ideally needs someone who isn't the author to test it, nothing personal, but we all know how badly we test our own software :-) |
Hmmm, the other CI builds seem to work without a problem. For some reason this one isn't getting picked up:
haha I understand. I'm always open to feedback if yall want to give it a try 😜 |
Maybe this is related to the deprecated Ubuntu 18.04 build configuration in the workflow. Could you try to rebase your branch on current GIT master? The workflow/CI configuration has been changed a lot in the last weeks. |
Add bracketcolors plugin. Color {}, [], () based on nesting order Closes geany#1148
* simple UI * start hooking up signals * mechanism to save settings from a conf file * save load settings for defaults button * less globals * better config color name * hook up colors * glib types * use colors from plugin config * update colors when settings change * reorganze, try to avoid giant files * update document colors when they switch * update headers * fix bug when some brackets werent getting added to bracket map * fix bug that was deleting newly inserted brackets * std::map insert doesnt overwrite, use insert_or_assign * handle when removing a bracket completes another * handle invalid color specs in config file * avoid static initialization fiasco * if there are problems loading config, use defaults * cleanup headers * mark GUI labels as translatable --------- Co-authored-by: Asif Amin <[email protected]>
f176f5c
to
44de64d
Compare
@eht16 I did the rebase, verified it compiles/works as expected on my rhel 8 workstation. Shall we give the CI another shot? |
It's from the pull request on my fork. I'd appreciate any feedback, I added some GUI elements to specify custom colors on the plugin preferences page. |
Any chance this could make it into geany-plugins v2.0? 👀 |
I'm afraid it's too late since the translation string freeze already happened. But we should finally review and merge it after 2.0. |
I think it would be useful and cool to colorize the indentation guides in a similar manner. Would this functionality be better as a separate plugin or would it make more sense to include it here but maybe rename the plugin? |
Good thing to ping it so "somebody" is reminded to try it and merge if they get a chance. Otherwise things get lost/forgotten, if it happens that nobody has time immediately, don't leave it nearly a year until the next ping. |
@b4n @elextr @eht16 @rdipardo I just pushed a bug fix for this I did a clean build of geany 2.1 and verified my plugin works as expected.
If there is anything else that is needed to get this merged in please let me know |
Bracketcolors plugin
How it works
Allocates 3 indicators (starting at
INDICATOR_IME
- 3) to color each bracket pair as determined bySCI_BRACEMATCH
. Ignore non source brackets as determined byhighlighting_is_code_style
Dependencies
INDICATOR_IME
from updated scintilla releasestd::map
Demo